<!--#
layout("/layouts/platform.html"){
#-->
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base!}/platform/goods/type" id="goback" data-pjax><i
                class="ti-angle-left"></i> ${msg['globals.button.back']}</a>
    </div>
    <div class="pull-right">
        <div class="btn-group tool-button">
            <button class="btn btn-primary navbar-btn" type="button" id="save"> ${msg['globals.button.save']}</button>
        </div>
    </div>
</header>

<div class="content-wrap">
    <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
          action="${base!}/platform/goods/type/editDo" method="post">
        <input type="hidden" id="id" name="id" value="${obj.id!}">
        <input type="hidden" id="physical" name="physical" value="${physical!}">
        <input type="hidden" id="hasBrand" name="hasBrand" value="${hasBrand!}">
        <input type="hidden" id="hasProp" name="hasProp" value="${hasProp!}">
        <input type="hidden" id="hasParam" name="hasParam" value="${hasParam!}">
        <input type="hidden" id="hasSpec" name="hasSpec" value="${hasSpec!}">
        <input type="hidden" id="hasTab" name="hasTab" value="${hasTab!}">
        <div class="wrapper" style="min-height:500px;">
            <div class="box-tab">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#base" data-toggle="tab">${msg['goods.type.column.defaultConfig']}</a>
                    </li>
                    <!--#if(1==hasProp){#-->
                    <li><a href="#props" data-toggle="tab">${msg['goods.type.column.extendedAttributes']}</a>
                    </li>
                    <!--#}#-->
                    <!--#if(1==hasSpec){#-->
                    <li><a href="#spec" data-toggle="tab">${msg['goods.type.column.standard']}</a>
                    </li>
                    <!--#}#-->
                    <!--#if(1==hasParam){#-->
                    <li><a href="#params" data-toggle="tab">${msg['goods.type.column.detailParams']}</a>
                    </li>
                    <!--#}#-->
                    <!--#if(1==hasTab){#-->
                    <li><a href="#mytab" data-toggle="tab">${msg['goods.type.column.customTAB']}</a>
                    </li>
                    <!--#}#-->
                    <!-- <li><a href="#price" data-toggle="tab">价格区间</a>
                     </li>-->
                </ul>
                <div class="tab-content text-center">
                    <div class="tab-pane fade active in" id="base">
                        <div class="col-lg-12">
                            <div class="form-group">
                                <label for="name"
                                       class="col-sm-2 control-label">${msg['goods.type.column.name']}</label>
                                <div class="col-sm-8">
                                    <input type="text" id="name" class="form-control" name="name"
                                           data-parsley-required="true"
                                           value="${obj.name!}" placeholder="${msg['goods.type.column.name']}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="aliasName" class="col-sm-2 control-label">${msg['goods.type.column.aliasName']}</label>

                                <div class="col-sm-8">
                                    <input type="text" id="aliasName" class="form-control" name="aliasName"
                                           value="${obj.aliasName!}"
                                           placeholder="${msg['goods.type.column.aliasName']}">
                                </div>
                            </div>
                            <!--#if(1==hasBrand){#-->
                            <div class="form-group">
                                <label for="brand"
                                       class="col-sm-2 control-label">${msg['goods.type.column.hasBrand']}</label>

                                <div class="col-sm-8" id="brand">
                                    <div style="float: left;height: 35px;line-height: 35px;">
                                        <!--#for(o in brandList){#-->
                                        <input type="checkbox" name="brand" value="${o.id!}">${o.name!}
                                        <!--#}#-->
                                    </div>
                                </div>
                            </div>
                            <!--#}#-->
                        </div>
                    </div>
                    <div class="tab-pane fade" id="props">
                        <div class="form-group">
                            <div class="col-sm-2">
                                <button id="propsAdd" type="button" class="btn btn-default"><i
                                        class="fa fa-plus mr5"></i>${msg['goods.type.column.addExtendedAttributes']}
                                </button>

                            </div>
                            <div class="col-sm-8">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="propsTab" class="col-sm-2 control-label"></label>
                            <div class="col-sm-8">
                                <table id="propsTab" width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <thead>
                                    <tr align="center">
                                        <td>${msg['goods.type.column.attributeName']}</td>
                                        <td width="2"></td>
                                        <td>${msg['goods.type.column.representation']}</td>
                                        <td width="2"></td>
                                        <td>${msg['goods.type.column.managementOptions']}</td>
                                        <td></td>
                                        <td>${msg['goods.type.column.operation']}</td>
                                    </tr>
                                    </thead>
                                    <TBODY> 　
                                    　<!--#for(o in obj.propsList){#-->
                                    <tr align="center">
                                        <td height="45">
                                            <input type="text" name="props_name" value="${o.name!}" class="form-control"
                                                   data-parsley-required="true"></td>
                                        <td width="2"></td>
                                        <td><select name="props_type" class="form-control">
                                            <option value="select" <!--#if(o.type=="select"){#-->selected<!--#}#-->
                                            >${msg['goods.type.column.dropDown']}</option>
                                            <option value="input" <!--#if(o.type=="input"){#-->selected<!--#}#-->
                                            >${msg['goods.type.column.textInputBox']}</option></select>
                                        <td width="2"></td>
                                        <td>
                                            <button type="button" <!--#if(o.type=="input"){#-->style="display:none"
                                            <!--#}#--> class="btn btn-default"><i class="fa fa-plus mr5"></i>${msg['goods.type.column.confChoose']}</button>
                                        </td>
                                        <td><input type="text" name="props_values"
                                                   value="<!--#for(k in o.propsValues){#-->${k.name!},<!--#}#-->"
                                                   class="form-control" style="width: 80px;" readonly></td>
                                        <td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.up']}"></i>
                                            <i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.down']}"></i>
                                            <i class="del fa fa-remove" style="cursor:pointer;padding: 5px;"
                                               title="${msg['globals.button.delete']}"></i></td>
                                    </tr>
                                    <!--#}#-->
                                    </TBODY>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="spec">
                        <div class="form-group">
                            <div class="col-sm-2">
                                <button id="specAdd" type="button" class="btn btn-default"><i
                                        class="fa fa-plus mr5"></i>${msg['goods.type.column.chooseStandard']}
                                </button>

                            </div>
                            <div class="col-sm-8">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="specTab" class="col-sm-2 control-label"></label>
                            <div class="col-sm-8">
                                <table id="specTab" width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <thead>
                                    <tr align="center">
                                        <td>${msg['goods.type.column.standardName']}</td>
                                        <td>${msg["goods.type.column.standardValue"]}</td>
                                        <td width="2"></td>
                                        <td>${msg['goods.type.column.operation']}</td>
                                    </tr>
                                    </thead>
                                    <TBODY> 　
                                    　<!--#for(o in obj.specList){#-->
                                    <tr align="center">
                                        <td height="45">
                                            <input type="hidden" name="specId" class="form-control"
                                                   value="${o.specId!}">
                                            <div class="specName">${o.spec.name!}</div>
                                        </td>
                                        <td><input type="hidden" name="specValueId" class="form-control" value="<!--#for(k in o.specValList){#-->${k.specValueId!},<!--#}#-->">
                                            <input type="hidden" name="specValUrls" class="form-control" value="<!--#for(k in o.specValList){#-->${k.specValUrl!},<!--#}#-->">
                                            <input type="text" name="specValText" value="<!--#for(k in o.specValList){#-->${k.specValText!},<!--#}#-->" class="form-control" style="width: 80px;" readonly></td>
                                        <td width="2"></td>
                                        <td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.up']}"></i>
                                            <i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.down']}"></i>
                                            <i class="del fa fa-remove" style="cursor:pointer;padding: 5px;"
                                               title="${msg['globals.button.delete']}"></i></td>
                                    </tr>
                                    <!--#}#-->
                                    </TBODY>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="params">
                        <div class="form-group">
                            <div class="col-sm-2">
                                <button id="groupAdd" type="button" class="btn btn-default"><i
                                        class="fa fa-plus mr5"></i>${msg['goods.type.column.addParams']}
                                </button>

                            </div>
                            <div class="col-sm-8">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="groupTab" class="col-sm-2 control-label"></label>
                            <div class="col-sm-8">
                                <table id="groupTab" width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <thead>
                                    <tr align="center">
                                        <td>${msg['goods.type.column.paramsName']}</td>
                                        <td width="2"></td>
                                        <td>${msg['goods.type.column.paramsManagement']}</td>
                                        <td></td>
                                        <td>${msg['goods.type.column.operation']}</td>
                                    </tr>
                                    </thead>
                                    <TBODY> 　
                                    　<!--#for(o in obj.paramgList){#-->
                                    <tr align="center">
                                        <td height="45">
                                            <input type="text" name="group_name" value="${o.name!}" class="form-control"
                                                   data-parsley-required="true"></td>
                                        <td width="2"></td>
                                        <td>
                                            <button type="button" class="btn btn-default"><i class="fa fa-plus mr5"></i>${msg['goods.type.column.name']}管理参数
                                            </button>
                                        </td>
                                        <td><input type="text" name="group_params"
                                                   value="<!--#for(k in o.params){#-->${k.name!},<!--#}#-->"
                                                   class="form-control" style="width: 80px;" readonly></td>
                                        <td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.up']}"></i>
                                            <i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.down']}"></i>
                                            <i class="del fa fa-remove" style="cursor:pointer;padding: 5px;"
                                               title="${msg['globals.button.delete']}"></i></td>
                                    </tr>
                                    <!--#}#-->
                                    </TBODY>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="mytab">
                        <div class="form-group">
                            <div class="col-sm-2">
                                <button id="tabAdd" type="button" class="btn btn-default"><i class="fa fa-plus mr5"></i>${msg['goods.type.column.addTags']}
                                </button>

                            </div>
                            <div class="col-sm-8">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="tabTab" class="col-sm-2 control-label"></label>
                            <div class="col-sm-8">
                                <table id="tabTab" width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <thead>
                                    <tr align="center">
                                        <td align="center" width="120">${msg['goods.type.column.tagsName']}</td>
                                        <td align="center">${msg['goods.type.column.edit']}</td>
                                        <td align="center"></td>
                                        <td align="center">${msg['goods.type.column.operation']}</td>
                                    </tr>
                                    </thead>
                                    <TBODY> 　
                                    　  <!--#for(o in obj.tabList){#-->
                                    <tr align="center">
                                        <td height="45">
                                            <input type="text" name="tab_name" value="${o.name!}" class="form-control"
                                                   style="width: 150px;" data-parsley-required="true"></td>
                                        <td>
                                            <button type="button" class="btn btn-default"><i class="fa fa-plus mr5"></i>${msg['goods.type.column.edit']}
                                            </button>
                                        </td>
                                        <td><input type="hidden" name="tab_note" value="${o.note!}" class="form-control"
                                                   style="width: 80px;" readonly></td>
                                        <td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.up']}"></i>
                                            <i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;"
                                               title="${msg['goods.type.column.down']}"></i>
                                            <i class="del fa fa-remove" style="cursor:pointer;padding: 5px;"
                                               title="${msg['globals.button.delete']}"></i></td>
                                    </tr>
                                    <!--#}#-->
                                    </TBODY>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div class="tab-pane fade" id="price">
                        <div class="form-group">
                            <div class="col-sm-2">
                                <button id="priceAdd" type="button" class="btn btn-default"><i
                                        class="fa fa-plus mr5"></i>${msg['goods.type.column.addTags']}
                                </button>

                            </div>
                            <div class="col-sm-8">
                            </div>
                        </div>
                    </div>


                </div>
            </div>
        </div>
    </form>
</div>
<div id="buttom"></div>
<div id="dialogProps" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">${msg['goods.type.column.editOptions']}</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="form-group">
                        <div class="col-sm-2">
                            <button id="dialogPropsAdd" type="button" class="btn btn-default"><i
                                    class="fa fa-plus mr5"></i>${msg['goods.type.column.addOptionValue']}
                            </button>
                        </div>
                        <div class="col-sm-8">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="form-group">
                        <label for="dialogPropsTab" class="col-sm-2 control-label"></label>
                        <div class="col-sm-8">
                            <table id="dialogPropsTab" width="100%" border="0" cellspacing="0" cellpadding="0">
                                <thead>
                                <tr align="center">
                                    <td>${msg['goods.type.column.optionValue']}</td>
                                    <td width="2"></td>
                                    <td>${msg['goods.type.column.operation']}</td>
                                </tr>
                                </thead>
                                <TBODY> 　
                                　
                                </TBODY>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">${msg['globals.button.cancel']}
                </button>
                <button id="dialogPropsOK" type="button" class="btn btn-primary"
                        data-loading-text="${msg['goods.type.column.enter']}">${msg['globals.button.confirm']}
                </button>
            </div>
        </div>
    </div>
</div>
<div id="dialogParam" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">${msg['goods.type.column.editParams']}</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="form-group">
                        <div class="col-sm-2">
                            <button id="dialogParamAdd" type="button" class="btn btn-default"><i
                                    class="fa fa-plus mr5"></i>${msg['goods.type.column.addParam']}
                            </button>
                        </div>
                        <div class="col-sm-8">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="form-group">
                        <label for="dialogPropsTab" class="col-sm-2 control-label"></label>
                        <div class="col-sm-8">
                            <table id="dialogParamTab" width="100%" border="0" cellspacing="0" cellpadding="0">
                                <thead>
                                <tr align="center">
                                    <td>${msg['goods.type.column.paramName']}</td>
                                    <td width="2"></td>
                                    <td>${msg['goods.type.column.operation']}</td>
                                </tr>
                                </thead>
                                <TBODY> 　
                                　
                                </TBODY>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">${msg['globals.button.cancel']}
                </button>
                <button id="dialogParamOK" type="button" class="btn btn-primary"
                        data-loading-text="${msg['goods.type.column.enter']}">${msg['globals.button.confirm']}
                </button>
            </div>
        </div>
    </div>
</div>
<!--#if(1==hasTab){#-->
<script src="${base!}/assets/plugins/ueditor/ueditor.config.js"></script>
<script src="${base!}/assets/plugins/ueditor/ueditor.all.min.js"></script>
<!--#}#-->
<div id="noteDialog" class="modal fade bs-modal-sm" tabindex="-2" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">${msg['goods.type.column.edit']}</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="form-group">
                        <textarea id="note" name="note" style="width:100%;height:200px;"></textarea>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">${msg['globals.button.cancel']}
                </button>
                <button id="noteOK" type="button" class="btn btn-primary"
                        data-loading-text="${msg['globals.button.confirm.tip']}">${msg['globals.button.confirm']}
                </button>
            </div>
        </div>
    </div>
</div>

<script language="JavaScript">
    var ue;
    function binPropsEvent() {
        $("#propsTab .up").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.prev();
            if (nextTR.length > 0) {
                nextTR.insertAfter(p);
            }
        });
        $("#propsTab .down").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.next();
            if (nextTR.length > 0) {
                nextTR.insertBefore(p);
            }
        });
        $("#propsTab .del").unbind("click").on("click", function () {
            var tr = $("#propsTab tbody").find("tr");
            if (tr.length > 0) {
                $(this).parent().parent().remove();
            }
        });
        $("#propsTab select").unbind("change").on("change", function () {
            if ("input" == $(this).val()) {
                $(this).parent().parent().find("button").hide();
                $(this).parent().parent().find("input[name='props_values']").hide();
                $(this).parent().parent().find("input[name='props_values']").val("");
            } else {
                $(this).parent().parent().find("button").show();
                $(this).parent().parent().find("input[name='props_values']").show();
            }
        });
        $("#propsTab .btn").unbind("click").on("click", function () {
            $("#dialogPropsTab tbody").html("");
            var btn = $(this);
            var vs = $(this).parent().parent().find("input[name='props_values']").val();
            if (vs != "" && vs.indexOf(",") > 0) {
                var vss = vs.split(",");
                for (var i = 0; i < vss.length - 1; i++) {
                    $("#dialogPropsTab tbody").append('<tr align="center"><td height="45">' +
                            '<input type="text" class="form-control" value="' + vss[i] + '"></td>' +
                            '<td width="2"></td>' +
                            '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                            '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                            '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
                }
                binDialogPropsEvent();
            }
            $("#dialogProps").modal("show");
            $("#dialogPropsOK").unbind("click").on("click", function () {
                var str = "";
                var ok = true;
                $("#dialogPropsTab").find("input").each(function () {
                    if ("" == $(this).val()) {
                        ok = false;
                        $(this).focus();
                        return false;
                    } else {
                        str += $(this).val() + ",";
                    }
                });
                if (ok) {
                    btn.parent().parent().find("input[name='props_values']").val(str);
                    $("#dialogProps").modal("hide");
                    $("#dialogPropsTab tbody").html("");
                }
            });
        });
    }
    function binDialogPropsEvent() {
        $("#dialogPropsTab .up").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.prev();
            if (nextTR.length > 0) {
                nextTR.insertAfter(p);
            }
        });
        $("#dialogPropsTab .down").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.next();
            if (nextTR.length > 0) {
                nextTR.insertBefore(p);
            }
        });
        $("#dialogPropsTab .del").unbind("click").on("click", function () {
            var tr = $("#propsTab tbody").find("tr");
            if (tr.length > 0) {
                $(this).parent().parent().remove();
            }
        });
    }
    //参数 start
    function binGroupEvent() {
        $("#groupTab .up").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.prev();
            if (nextTR.length > 0) {
                nextTR.insertAfter(p);
            }
        });
        $("#groupTab .down").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.next();
            if (nextTR.length > 0) {
                nextTR.insertBefore(p);
            }
        });
        $("#groupTab .del").unbind("click").on("click", function () {
            var tr = $("#groupTab tbody").find("tr");
            if (tr.length > 0) {
                $(this).parent().parent().remove();
            }
        });
        $("#groupTab .btn").unbind("click").on("click", function () {
            $("#dialogParamTab tbody").html("");
            var btn = $(this);
            var vs = $(this).parent().parent().find("input[name='group_params']").val();
            if (vs != "" && vs.indexOf(",") > 0) {
                var vss = vs.split(",");
                for (var i = 0; i < vss.length - 1; i++) {
                    $("#dialogParamTab tbody").append('<tr align="center"><td height="45">' +
                            '<input type="text" class="form-control" value="' + vss[i] + '"></td>' +
                            '<td width="2"></td>' +
                            '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                            '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                            '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
                }
                binDialogGroupEvent();
            }
            $("#dialogParam").modal("show");
            $("#dialogParamOK").unbind("click").on("click", function () {
                var str = "";
                var ok = true;
                $("#dialogParamTab").find("input").each(function () {
                    if ("" == $(this).val()) {
                        ok = false;
                        $(this).focus();
                        return false;
                    } else {
                        str += $(this).val() + ",";
                    }
                });
                if (ok) {
                    btn.parent().parent().find("input[name='group_params']").val(str);
                    $("#dialogParam").modal("hide");
                    $("#dialogParamTab tbody").html("");
                }
            });
        });
    }
    function binDialogGroupEvent() {
        $("#dialogParamTab .up").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.prev();
            if (nextTR.length > 0) {
                nextTR.insertAfter(p);
            }
        });
        $("#dialogParamTab .down").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.next();
            if (nextTR.length > 0) {
                nextTR.insertBefore(p);
            }
        });
        $("#dialogParamTab .del").unbind("click").on("click", function () {
            var tr = $("#dialogParamTab tbody").find("tr");
            if (tr.length > 0) {
                $(this).parent().parent().remove();
            }
        });
    }
    // 参数 end
    function binSpecEvent() {
        $("#specTab .up").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.prev();
            if (nextTR.length > 0) {
                nextTR.insertAfter(p);
            }
        });
        $("#specTab .down").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.next();
            if (nextTR.length > 0) {
                nextTR.insertBefore(p);
            }
        });
        $("#specTab .del").unbind("click").on("click", function () {
            var tr = $("#specTab tbody").find("tr");
            if (tr.length > 0) {
                $(this).parent().parent().remove();
            }
        });
    }
    function binTabEvent() {
        $("#tabTab .btn").unbind("click").on("click", function () {
            var btn = $(this);
            var p = $(this).parent().parent();
            ue.setContent("" + p.find("input[name=tab_note]").val());
            $("#noteOK").unbind("click").on("click", function () {
                p.find("input[name=tab_note]").val(ue.getContent());
                $("#noteDialog").modal("hide");
            });
            $("#noteDialog").modal("show");
        });
        $("#tabTab .up").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.prev();
            if (nextTR.length > 0) {
                nextTR.insertAfter(p);
            }
        });
        $("#tabTab .down").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.next();
            if (nextTR.length > 0) {
                nextTR.insertBefore(p);
            }
        });
        $("#tabTab .del").unbind("click").on("click", function () {
            var tr = $("#tabTab tbody").find("tr");
            if (tr.length > 0) {
                $(this).parent().parent().remove();
            }
        });
    }
    function binPriceEvent() {
        $("#priceTab .up").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.prev();
            if (nextTR.length > 0) {
                nextTR.insertAfter(p);
            }
        });
        $("#priceTab .down").unbind("click").on("click", function () {
            var p = $(this).parent().parent();
            var nextTR = p.next();
            if (nextTR.length > 0) {
                nextTR.insertBefore(p);
            }
        });
        $("#priceTab .del").unbind("click").on("click", function () {
            var tr = $("#priceTab tbody").find("tr");
            if (tr.length > 0) {
                $(this).parent().parent().remove();
            }
        });
    }
    $(document).ready(function () {
        <!--#for(o in obj.brandList){#-->
        $("input[name=brand][value=${o.brandId!}]").attr("checked", true);
        <!--#}#-->
        <!--#if(1==hasTab){#-->
        setTimeout(function () {
            ue = new baidu.editor.ui.Editor();
            ue.render('note');
        }, 500);
        <!--#}#-->
        binSpecEvent();
        binPropsEvent();
        binGroupEvent();
        binTabEvent();
        $("#groupAdd").on("click", function () {
            $("#groupTab tbody").append('<tr align="center"><td height="45">' +
                    '<input type="text" name="group_name" class="form-control" data-parsley-required="true"></td>' +
                    '<td width="2"></td><td><button type="button" class="btn btn-default"><i class="fa fa-plus mr5"></i>管理参数</button></td>' +
                    '<td><input type="text" name="group_params" class="form-control" style="width: 80px;" readonly></td>' +
                    '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                    '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                    '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
            binGroupEvent();
        });
        $("#dialogParamAdd").on("click", function () {
            $("#dialogParamTab tbody").append('<tr align="center"><td height="45">' +
                    '<input type="text" class="form-control"></td>' +
                    '<td width="2"></td>' +
                    '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                    '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                    '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
            binDialogGroupEvent();
        });
        $("#tabAdd").on("click", function () {
            $("#tabTab tbody").append('<tr align="center"><td height="45">' +
                    '<input type="text" name="tab_name" class="form-control" style="width: 150px;" data-parsley-required="true"></td>' +
                    '<td><button type="button" class="btn btn-default"><i class="fa fa-plus mr5"></i>编辑内容</button></td>' +
                    '<td><input type="hidden" name="tab_note" class="form-control" style="width: 80px;" readonly></td>' +
                    '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                    '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                    '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
            binTabEvent();
        });
        $("#priceAdd").on("click", function () {
            $("#priceTab tbody").append('<tr align="center"><td height="45">' +
                    '<input type="text" name="price_min" class="form-control" parsley-type="integer"  style="width: 150px;" data-parsley-required="true"></td>' +
                    '<td><input type="text" name="price_max" class="form-control" parsley-type="number" style="width: 150px;" data-parsley-required="true"></td>' +
                    '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                    '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                    '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
            binPriceEvent();
        });
        $("#propsAdd").on("click", function () {
            $("#propsTab tbody").append('<tr align="center"><td height="45">' +
                    '<input type="text" name="props_name" class="form-control" data-parsley-required="true"></td>' +
                    '<td width="2"></td>' +
                    '<td><select name="props_type" class="form-control"><option value="select">下拉框</option><option value="input">文本输入框</option></select> ' +
                    '<td width="2"></td><td><button type="button" class="btn btn-default"><i class="fa fa-plus mr5"></i>管理选项</button></td>' +
                    '<td><input type="text" name="props_values" class="form-control" style="width: 80px;" readonly></td>' +
                    '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                    '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                    '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
            binPropsEvent();
        });
        $("#dialogPropsAdd").on("click", function () {
            $("#dialogPropsTab tbody").append('<tr align="center"><td height="45">' +
                    '<input type="text" class="form-control"></td>' +
                    '<td width="2"></td>' +
                    '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                    '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                    '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
            binDialogPropsEvent();
        });
        $("#specAdd").on("click", function () {
            $("#buttom").load("${base!}/platform/goods/type/spec", function (response, status, xhr) {
                $("#dialogSpecOK").on("click", function () {
                    var spec = $("#dialogSpec input[type=radio]:checked").val();
                    var text = $("#dialogSpec input[type=radio]:checked + span").text();
                    if (spec) {
                        var ok = true;
                        $("#specTab").find("input[name='specId']").each(function () {
                            if (spec == $(this).val()) {
                                Toast.warning("规格已存在");
                                ok = false;
                            }
                        });
                        if (ok) {
                            var specValIds = "";
                            var specValText = "";
                            var specValUrl = "";

                            $("#specList").find("button").each(function () {
                                if ($(this).hasClass("btn-select")) {
                                    specValIds += $(this).attr("data-id") + ",";
                                    specValUrl += $(this).attr("data-url") == "undefined" ? "" : $(this).attr("data-url") + ",";
                                    specValText += $(this).text() + ",";
                                }
                            });

                            $("#specTab tbody").append('<tr align="center"><td height="45">' +
                                    '<input type="hidden" name="specId" class="form-control" value="' + spec + '"><div class="specName">' + text + '</div></td>' +
                                    '<td><input type="hidden" name="specValueId" class="form-control" value="' + specValIds + '">' +
                                    '<input type="hidden" name="specValUrls" class="form-control" value="'+specValUrl+'">' +
                                    '<input type="text" name="specValText" value="' + specValText + '" class="form-control" style="width: 80px;" readonly></td>' +
                                    '<td width="2"></td>' +
                                    '<td><i class="up fa fa-arrow-up" style="cursor:pointer;padding: 5px;" title="向上移动"></i>' +
                                    '<i class="down fa fa-arrow-down" style="cursor:pointer;padding: 5px;" title="向下移动"></i>' +
                                    '<i class="del fa fa-remove" style="cursor:pointer;padding: 5px;" title="删除"></i></td></tr>');
                            binSpecEvent();
                            $("#dialogSpec").modal("hide");
                        }
                    } else {
                        Toast.warning("请选择一个规格");
                    }
                });
                $("#dialogSpec").modal("show");
            });
        });
        $('#addForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    //刷新父级菜单
                    form.resetForm();
                    setTimeout(function () {
                        $("#goback").trigger("click");
                    }, 1000);
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });
        $("#save").on("click", function () {
            $('#addForm').submit();
        });

    });
</script>

<!--#}#-->